package com.example.bottomnavigationkotlin.ui.home

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.fragment.app.Fragment
import com.example.bottomnavigationkotlin.R

class ProductDetailFragment : Fragment() {
    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        return inflater.inflate(R.layout.fragment_product_detail, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        val title = arguments?.getString("title") ?: ""
        val price = arguments?.getString("price") ?: ""
        val imageResId = arguments?.getInt("imageResId") ?: 0

        view.findViewById<TextView>(R.id.tv_detail_title).text = title
        view.findViewById<TextView>(R.id.tv_detail_price).text = price
        view.findViewById<ImageView>(R.id.iv_detail_image).setImageResource(imageResId)
    }

    companion object {
        fun newInstance(title: String, price: String, imageResId: Int): ProductDetailFragment {
            val fragment = ProductDetailFragment()
            val args = Bundle()
            args.putString("title", title)
            args.putString("price", price)
            args.putInt("imageResId", imageResId)
            fragment.arguments = args
            return fragment
        }
    }
} 